package com.ruoyi.system.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.SelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsWarehouseRack;
import com.ruoyi.system.service.IWmsWarehouseRackService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货架信息Controller
 *
 * @author ruoyi
 * @date 2025-06-17
 */
@RestController
@RequestMapping("/system/wmsWarehouseRack")
public class WmsWarehouseRackController extends BaseController
{
    @Autowired
    private IWmsWarehouseRackService wmsWarehouseRackService;

    /**
     * 查询货架信息列表
     */
    @SaCheckPermission("system:rack:list")
    @GetMapping("/list")
    public TableDataInfo<WmsWarehouseRack> list(WmsWarehouseRack wmsWarehouseRack, PageQuery pageQuery)
    {
        return wmsWarehouseRackService.selectWmsWarehouseRackList(wmsWarehouseRack,pageQuery);
    }

    /**
     * 导出货架信息列表
     */
    /*@SaCheckPermission("system:rack:export")
    @Log(title = "货架信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehouseRack wmsWarehouseRack)
    {
        List<WmsWarehouseRack> list = wmsWarehouseRackService.selectWmsWarehouseRackList(wmsWarehouseRack);
        ExcelUtil<WmsWarehouseRack> util = new ExcelUtil<WmsWarehouseRack>(WmsWarehouseRack.class);
        util.exportExcel(response, list, "货架信息数据");
    }*/

    /**
     * 获取货架信息详细信息
     */
    @SaCheckPermission("system:rack:query")
    @GetMapping(value = "/{rackId}")
    public R<WmsWarehouseRack> getInfo(@PathVariable("rackId") Long rackId)
    {
        return R.ok(wmsWarehouseRackService.selectWmsWarehouseRackByRackId(rackId));
    }

    /**
     * 新增货架信息
     */
    @SaCheckPermission("system:rack:add")
    @Log(title = "货架信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsWarehouseRack wmsWarehouseRack)
    {
        return toAjax(wmsWarehouseRackService.insertWmsWarehouseRack(wmsWarehouseRack));
    }

    /**
     * 修改货架信息
     */
    @SaCheckPermission("system:rack:edit")
    @Log(title = "货架信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsWarehouseRack wmsWarehouseRack)
    {
        return toAjax(wmsWarehouseRackService.updateWmsWarehouseRack(wmsWarehouseRack));
    }

    /**
     * 删除货架信息
     */
    @SaCheckPermission("system:rack:remove")
    @Log(title = "货架信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rackIds}")
    public R<Void> remove(@PathVariable Long[] rackIds)
    {
        return toAjax(wmsWarehouseRackService.deleteWmsWarehouseRackByRackIds(rackIds));
    }



    /**
     * 查询商品品牌列表
     */
    @SaCheckPermission("system:rack:list")
    @GetMapping("/getWarehouseRackSelect")
    public R<List<SelectVo>> getWarehouseRackSelect(){
        return R.ok(wmsWarehouseRackService.getWarehouseRackSelect());
    }


    /**
     * 查询商品品牌列表
     */
    @SaCheckPermission("system:rack:list")
    @GetMapping("/getWarehouseRackSelectWarehouseAreaId")
    public R<List<SelectVo>> getWarehouseRackSelectWarehouseAreaId(@RequestParam(required = false) Long warehouseAreaId){
        return R.ok(wmsWarehouseRackService.getWarehouseRackSelectWarehouseAreaId(warehouseAreaId));
    }
}
